/**
 * Created by Jackl on 2018/7/14.
 */

export class Cache{
    readonly obj: Object;

    constructor(){
        this.obj = new Object;
    }

    get(key: string): any{
       const desc =  Object.getOwnPropertyDescriptor(this.obj, key);
       if(desc){
           return desc.value;
       }
       return void 0;
    }

    put(key: string, value: any) :void{
        Object.defineProperty(this.obj, key, {
            value: value,
            enumerable: true
        });
    }

    values(): Array<any>{
        var values = new Array;

        for(let key in this.obj){
            values.push(this.get(key));
        }
        return values;
    }
}